package com.ruoyi.system.service.impl;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.SysPropertyCommentMapper;
import com.ruoyi.common.core.domain.entity.SysPropertyComment;
import com.ruoyi.system.service.ISysPropertyCommentService;

/**
 * 房源评论id关联表Service业务层处理
 * 
 * @author ssd
 * @date 2024-04-04
 */
@Service
public class SysPropertyCommentServiceImpl implements ISysPropertyCommentService 
{
    @Autowired
    private SysPropertyCommentMapper sysPropertyCommentMapper;


    /**
     * 查询房源评论id关联表
     * 
     * @param propertyId 房源评论id关联表主键
     * @return 房源评论id关联表
     */
    @Override
    public SysPropertyComment selectSysPropertyCommentByPropertyId(Long propertyId)
    {
        return sysPropertyCommentMapper.selectSysPropertyCommentByPropertyId(propertyId);
    }

    /**
     * 查询房源评论id关联表列表
     * 
     * @param sysPropertyComment 房源评论id关联表
     * @return 房源评论id关联表
     */
    @Override
    public List<SysPropertyComment> selectSysPropertyCommentList(SysPropertyComment sysPropertyComment)
    {
        return sysPropertyCommentMapper.selectSysPropertyCommentList(sysPropertyComment);
    }

    /**
     * 新增房源评论id关联表
     * 
     * @param sysPropertyComment 房源评论id关联表
     * @return 结果
     */
    @Override
    public int insertSysPropertyComment(SysPropertyComment sysPropertyComment)
    {
        return sysPropertyCommentMapper.insertSysPropertyComment(sysPropertyComment);
    }

    @Override
    public int insertSysPropertyCommentList(Long commentId, List<Long> ids) {
        int insertedCount = 0; // 记录成功插入的次数

        for (Long id : ids) {
            // 创建新对象并设置关联属性
            SysPropertyComment sysPropertyComment = new SysPropertyComment();
            sysPropertyComment.setCommentId(commentId);
            sysPropertyComment.setPropertyId(id);

            // 尝试插入记录
            int result = sysPropertyCommentMapper.insertSysPropertyComment(sysPropertyComment);
            if (result > 0) {
                insertedCount++; // 计数成功插入的记录
            }
        }

        return insertedCount; // 返回成功插入的记录数量
    }

    /**
     * 修改房源评论id关联表
     * 
     * @param sysPropertyComment 房源评论id关联表
     * @return 结果
     */
    @Override
    public int updateSysPropertyComment(SysPropertyComment sysPropertyComment)
    {
        return sysPropertyCommentMapper.updateSysPropertyComment(sysPropertyComment);
    }

    /**
     * 批量删除房源评论id关联表
     * 
     * @param propertyIds 需要删除的房源评论id关联表主键
     * @return 结果
     */
    @Override
    public int deleteSysPropertyCommentByPropertyIds(Long[] propertyIds)
    {
        return sysPropertyCommentMapper.deleteSysPropertyCommentByPropertyIds(propertyIds);
    }

    /**
     * 删除房源评论id关联表信息
     * 
     * @param propertyId 房源评论id关联表主键
     * @return 结果
     */
    @Override
    public int deleteSysPropertyCommentByPropertyId(Long propertyId)
    {
        return sysPropertyCommentMapper.deleteSysPropertyCommentByPropertyId(propertyId);
    }
}
